﻿using PengSW.HeartBeat;

namespace PengSW.Monitor
{
    /// <summary>
    /// 基于心跳的监视目标
    /// </summary>
    public class MonitorTarget_HeartBeat : IMonitorTarget
    {
        public MonitorTarget_HeartBeat(string aHost, string aServiceName, int aPort = 808)
        {
            Host = aHost;
            ServiceName = aServiceName;
            Port = aPort;
        }

        public string Host { get; private set; }
        public string ServiceName { get; private set; }
        public int Port { get; private set; }

        public string Description
        {
            get { return string.Format("HeartBeat of [{0}]:[{1}]", Host, ServiceName); }
        }

        public bool IsAlive
        {
            get { return HeartBeatServiceClient.TestHeartBeat(Host, ServiceName, Port); }
        }
    }
}
